print("Введите скобочную последователность: ")
s = input()
s1 = ""

c_open = 0
c_close = 0



for char in s:
    if char == '(':
        c_open += 1
    if char == ')':
        c_close += 1
        print ("Открытых: ", c_open)
        print ("Закрытых: ", c_close)



for char in s:
    if char == '(':
        s1 += char
    if char == ')':
        if len(s1)>0:
            if s1[len(s1)-1] == '(':
                s1 = s1[:-1]
    if char == '[':
        s1 += char
        
    if char == ']':
        if len(s1)>0:
            if s1[len(s1)-1] == '[':
                s1 = s1[:-1]
    print(s1)
if len (s1) == 0:
    print("Верное")
else:
    print("Неверное")
        
        

        
